//
//  SunResignSuccessVC.m
//  Xspcf
//
//  Created by sunshine on 2017/6/29.
//  Copyright © 2017年 小小算盘. All rights reserved.
//

#import "SunResignSuccessVC.h"
#import "SunOpenBindVC.h"

@interface SunResignSuccessVC ()
{
    UIImageView *_img;
}
@end

@implementation SunResignSuccessVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"注册成功";
    self.view.backgroundColor = BACKGROUND;
    [self createUI];
    [self requestToImg];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundImage:[UIImage imageNamed:@"tool_back"] forState:UIControlStateNormal];
    [btn setFrame:CGRectMake(0, 0, 20, 20)];
    [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    // Do any additional setup after loading the view.
}

- (void)back{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)createUI{
    UILabel *la = [[UILabel alloc]init];
    [self.view addSubview:la];
    [la lt_setTop:Y(50) to:nil save:YES];
    [la lt_XcenterTo:nil save:YES];
    la.textColor = RED;
    la.text = @"恭喜您！获得以下新手奖励！";
    _img = [[UIImageView alloc]init];
    [self.view addSubview:_img];
    [_img lt_Top:SunEdgesMake(Y(16), X(21), X(21), Y(206)) to:la save:YES];
    UILabel *l2 = [[UILabel alloc]init];
    [self.view addSubview:l2];
    [l2 lt_XcenterTo:nil save:YES];
    [l2 lt_setTop:Y(60) to:_img save:YES];
    l2.textColor = GRAY;
    l2.font = FONT(12);
    l2.text = @"为了保障您的资金安全请开通银行资金存管账户";
    UIButton *btn = [[UIButton alloc] init];
    [self.view addSubview:btn];
    [btn lt_Top:SunEdgesMake(Y(14), X(15), X(15), Y(44)) to:l2 save:YES];
    btn.clipsToBounds = YES;
    [btn setBackgroundColor:BLUE forState:UIControlStateNormal];
    [btn setBackgroundColor:[HXColor colorWithHexString:@"87CEFA"] forState:UIControlStateHighlighted];
    btn.layer.cornerRadius = 4;
    [btn setTitle:@"开通资金存管账户" forState:UIControlStateNormal];
    [btn setTitleColor:WHITE forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:17];
    [btn addTarget:self action:@selector(open) forControlEvents:UIControlEventTouchUpInside];
    UIButton *btn2 = [[UIButton alloc]init];
    [self.view addSubview:btn2];
    [btn2 lt_XcenterTo:nil save:YES];
    [btn2 lt_setTop:Y(14) to:btn save:YES];
    [btn2 setTitle:@"再逛逛稍后开通" forState:UIControlStateNormal];
    [btn2 setTitleColor:BLUE forState:UIControlStateNormal];
    btn2.titleLabel.font = FONT(10);
    [btn2 addTarget:self action:@selector(goHome) forControlEvents:UIControlEventTouchUpInside];
}


- (void)open{
    SunOpenBindVC *vc = [[SunOpenBindVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)goHome{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (BOOL)navigationShouldPopOnBackButton {
    [self goHome];
    return false;
}

- (void)requestToImg{
    NSString *url = [NSString stringWithFormat:@"%@%@",KURL,API_REGISTERIMG];
    [HttpRequest postURL:url withParam:nil success:^(id requestDic, NSString *msg) {
        NSString *imgUrl = [NSString stringWithFormat:@"%@%@",KIMG,[requestDic objectForKey:@"img"]];
        [_img sd_setImageWithURL:[NSURL URLWithString:imgUrl]];
    } failure:^(NSString *errorInfo, int code) {
        [[Sun shareSun]showMsg:errorInfo];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
